<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>选择分享类型</title>


    <link rel="stylesheet" href="/css/weui.css"/>
    <link rel="stylesheet" href="/css/weuix.css"/>
    <script src="/js/zepto.min.js"></script>
    <script src="/js/zepto.weui.js"></script>
    <script src="/js/php.js"></script>
    <style>
        .head {
            background: url("img/title.png") no-repeat;
            background-size: contain;
            width: 100%;
            height: 80px;
            margin-bottom: 10px;
        }

        .weui-cell__hd  {
            background-color: pink;
            height: 46px;
            width: 50px !important;
            vertical-align: text-bottom;
        }

        .hd1 {
            background: url("img/share_style_icon.png");
            background-position: 0 -166px;
            background-size: 84px;

        }

        .hd2 {
            background: url("img/share_style_icon.png");
            background-position: 0 -240px;
            background-size: 84px;
            vertical-align: middle;
        }

        .weui-cell__bd p {
        padding-left: 20px;
        font-weight: 500;
            padding-top: 3px;
            line-height: 46px;
        }

        .ft1 {
            height: 50px;
            width: 40px;
            background: url("img/share_style_icon2.png");
            background-position: 0 -621px;
            background-size: 80px;
        }

        .ft2 {
            height: 50px;
            width: 40px;
            background: url("img/share_style_icon2.png");
            background-position: 0 -621px;
            background-size: 80px;
        }

        .weui-cells {
            width: 90%;
            margin: 0 auto;
        }

        body {
            background-color: #f4f4f4;
        }

        a {
            line-height: 50px;
        }
    </style>
</head>
<body>
    <div class="head">

    </div>

    <div class="weui-cells">

        <a id="to_publish" class="weui-cell weui-cell_access" onclick="myshare('pc')" href="javascript:;">
            <div class="weui-cell__hd hd1"></div>
            <div class="weui-cell__bd bd1">
                <p>邀请发布问卷</p>
            </div>
            <div class="ft1"></div>
        </a>
        <a id="to_write"  class="weui-cell weui-cell_access" onclick="myshare('smapp')" href="javascript:;">
            <div class="weui-cell__hd hd2"></div>
            <div class="weui-cell__bd">
                <p>邀请填写问卷</p>
            </div>
            <div class="ft2"></div>
        </a>
    </div>



        <input name="unionid" type="hidden"  id="unionid" th:value="${partnerUnionid}">


    <script src="http://res.wx.qq.com/open/js/jweixin-1.6.0.js"></script>

    <script>
        $(
            function () {

            }
        )
        var unionid = $("#unionid").val();
        var baseUrl = "http://mengwen.natapp1.cc/pc";
        var wxData = {}
        // var baseUrl = "";
        function myshare(type){
            if (type == 'pc'){
                baseUrl = 'http://mengwen.natapp1.cc/pc?unionid=' + unionid;
                // alert(baseUrl)
                // var baseUrl = "http://www.baidu.com"; //分享Js接口安全域名URL
                wxData = {
                    "imgUrl": 'http://mengwen.natapp1.cc/img/logo.jpg', //分享图标
                    "link": baseUrl,
                    "title": '萌问趣答创建问卷邀请函',
                    "desc": '萌问趣答，重新定义调查问卷'
                };
                wx.ready(function () {
                    wx.onMenuShareTimeline({
                        title: wxData.title,
                        link: wxData.link,
                        imgUrl: wxData.imgUrl,
                        type: 'link',
                        success: function () {
                            alert('分享成功')
                        }
                    });
                    wx.onMenuShareAppMessage({
                        title: wxData.title,
                        desc: wxData.desc,
                        link: wxData.link,
                        imgUrl: wxData.imgUrl,
                        type: 'link',
                        dataUrl: '',
                        success: function () {
                        }
                    });
                })
            }else {
                baseUrl = 'http://mengwen.natapp1.cc/smapp?unionid=' + unionid;

                wxData = {
                    "imgUrl": 'http://mengwen.natapp1.cc/img/logo.jpg', //分享图标
                    "link": baseUrl,
                    "title": '萌问趣答小程序端邀请函',
                    "desc": '填问卷，拿钱，来这里！'
                };

                wx.ready(function () {
                    wx.onMenuShareTimeline({
                        title: wxData.title,
                        link: wxData.link,
                        imgUrl: wxData.imgUrl,
                        type: 'link',
                        success: function () {
                            alert('分享成功')
                        }
                    });
                    wx.onMenuShareAppMessage({
                        title: wxData.title,
                        desc: wxData.desc,
                        link: wxData.link,
                        imgUrl: wxData.imgUrl,
                        type: 'link',
                        dataUrl: '',
                        success: function () {
                        }
                    });
                })
            }
            var sharetpl='<div class="weui-share" onclick="$(this).remove();">\n' +
                '<div class="weui-share-box">\n' +
                '合伙人你好，点击右上角发送给指定朋友或分享到朋友圈哦！ <i></i>\n' +
                '</div>\n' +
                '</div>';
            var sharetpl = $.t7.compile(sharetpl);
            $("body").append(sharetpl());

        }


        $(
            function () {


                $.ajax({
                    url:"/get_parameter",    //请求的url地址
                    dataType:"json",   //返回格式为json
                    async:true,//请求是否异步，默认为异步，这也是ajax重要特性
                    data:{"id":"value"},    //参数值
                    type:"POST",   //请求方式
                    beforeSend:function(){
                        //请求前的处理
                    },
                    success:function(jsSdkDto){
                        //请求成功时处理
                        wx.config({
                            debug: false,
                            appId: jsSdkDto.appId,
                            timestamp: jsSdkDto.timestamp,
                            nonceStr: jsSdkDto.nonceStr,
                            signature: jsSdkDto.signature,
                            jsApiList: ['onMenuShareTimeline',
                                'onMenuShareAppMessage',
                                'onMenuShareQQ'
                            ]  // 必填，需要使用的JS接口列表
                        });//end_config
                    },
                    complete:function(){
                        //请求完成的处理
                    },
                    error:function(){
                        //请求出错处理
                    }
                });


            }
        );








    </script>
</body>
</html>